import Vue from 'vue'

//不能放在main.js中，循环依赖会导致build不过
export function http(host, uri, method, data, {timeout = 10000, headers = {}, upload = {}} = {}) {
  var options = {
    url: host + encodeURI(uri),
    method: method,
    timeout: timeout, 
    data: data,
    headers: headers,
    upload: upload,
    xhr: {
      withCredentials: true
    }
  }
  return Vue.http(options)
}